/*----------------------------------------------------------------------
 *
 * A simple bus interface module based loosely on Intels
 * Low Pincount Bus.
 *
 *---------------------------------------------------------------------*/


module dcom_lpcb

  (/*AUTOARG*/
  // Outputs
  rxd_out, lpcb_frame_out, lpcb_cad_out,
  // Inputs
  clk, clk_en, reset, txd_in, dcom_scaler, lpcb_frame_in, lpcb_cad_in
  );

  //----------------------------------------
  input                 clk;
  input                 clk_en;

  input                 reset;
  //----------------------------------------

  //----------------------------------------
  // serial port interface.
  input                 txd_in;
  output                rxd_out;

  // scaler value is supplied externally
  // values are clock rate / (8 x baud rate) - 1, so for:
  // 115200 @ 100MHz = 108
  //  57600 @ 100MHz = 216
  // 115200 @  90MHz =  97
  //  57600 @  90MHz = 194
  // 115200 @  50MHz =  53
  //  57600 @  50MHz = 108
  input [7:0]           dcom_scaler;
  //----------------------------------------

  //----------------------------------------
  // lpcb interface
  output                lpcb_frame_out;
  output[3:0]           lpcb_cad_out;

  input                 lpcb_frame_in;
  input [3:0]           lpcb_cad_in;
  //----------------------------------------

  /*----------------------------------------------------------------*/

  /*-AUTOUNUSED-*/

  /*AUTOINPUT*/

  /*AUTOOUTPUT*/

  /*-AUTOREGINPUT-*/

  /*AUTOREG*/

  /*AUTOWIRE*/
  // Beginning of automatic wires (for undeclared instantiated-module outputs)
  wire [7:0]            rx_data;                // From uart of dcom_uart.v
  wire                  rx_data_valid;          // From uart of dcom_uart.v
  wire                  rx_error;               // From uart of dcom_uart.v
  wire [7:0]            tx_data;                // From lpcb_if of dcom_lpcb_if.v
  wire                  tx_data_valid;          // From lpcb_if of dcom_lpcb_if.v
  wire                  tx_ready;               // From uart of dcom_uart.v
  // End of automatics

  /*------------------------------------------------------------------
   *
   * local definitions and connections.
   *
   * */

  /*-----------------------------------------------------------------
   *
   *
   *
   * */

  dcom_uart uart
    (/*AUTOINST*/
     // Outputs
     .rxd_out                           (rxd_out),
     .rx_data                           (rx_data[7:0]),
     .rx_data_valid                     (rx_data_valid),
     .rx_error                          (rx_error),
     .tx_ready                          (tx_ready),
     // Inputs
     .clk                               (clk),
     .clk_en                            (clk_en),
     .reset                             (reset),
     .txd_in                            (txd_in),
     .dcom_scaler                       (dcom_scaler[7:0]),
     .tx_data                           (tx_data[7:0]),
     .tx_data_valid                     (tx_data_valid));

  dcom_lpcb_if lpcb_if
    (/*AUTOINST*/
     // Outputs
     .tx_data                           (tx_data[7:0]),
     .tx_data_valid                     (tx_data_valid),
     .lpcb_frame_out                    (lpcb_frame_out),
     .lpcb_cad_out                      (lpcb_cad_out[3:0]),
     // Inputs
     .clk                               (clk),
     .clk_en                            (clk_en),
     .reset                             (reset),
     .rx_data                           (rx_data[7:0]),
     .rx_data_valid                     (rx_data_valid),
     .rx_error                          (rx_error),
     .tx_ready                          (tx_ready),
     .lpcb_frame_in                     (lpcb_frame_in),
     .lpcb_cad_in                       (lpcb_cad_in[3:0]));

  /*----------------------------------------------------------------*/

endmodule // dcom_lpcb


// Local Variables:
// verilog-library-directories:("." "../dcom_uart")
// verilog-library-extensions:(".v")
// End:
